# coding: utf-8
from datetime import datetime
from sqlalchemy import Column, String, DATETIME, text, func
from sqlalchemy.dialects.mysql import INTEGER, TINYINT, MEDIUMINT, MEDIUMTEXT
from ..database import db,serialize


class Menu(db.Model):
    __tablename__ = 'menus'

    id = Column(INTEGER(10), primary_key=True)
    parentid = Column(INTEGER(11), nullable=False)
    arrparentid = Column(String(255, 'utf8mb4_unicode_ci'), server_default=text("'0'"))
    child = Column(TINYINT(1), nullable=False, server_default=text("'0'"))
    arrchildid = Column(MEDIUMTEXT)
    name = Column(String(20, 'utf8mb4_unicode_ci'), nullable=False)
    url = Column(String(100, 'utf8mb4_unicode_ci'), nullable=False)
    label = Column(String(100, 'utf8mb4_unicode_ci'), nullable=False)
    icon = Column(String(50, 'utf8mb4_unicode_ci'))
    display = Column(TINYINT(3), nullable=False, server_default=text("'1'"))
    sort = Column(MEDIUMINT(8), nullable=False, server_default=text("'0'"))
    created_at = Column(DATETIME, default=datetime.now())
    updated_at = Column(DATETIME, default=datetime.now(
    ), server_default=func.now(), onupdate=func.now(), comment='修改时间')
